// ArrayBuffer转16进制字符串示例
export const ab2hex = buffer => {
    let hexArr = Array.prototype.map.call(new Uint8Array(buffer), function (
        bit
    ) {
        return ("00" + bit.toString(16)).slice(-2);
    });
    return hexArr;
}
//10进制数组转ArrayBuffer
export const arr2ab = arr => {
    // console.log(arr.length);
    const buffer = new ArrayBuffer(arr.length);
    const dataView = new DataView(buffer);
    for (var i = 0; i < arr.length; i++) {
        dataView.setUint8(i, arr[i]);
    }
    return buffer;
}